/**
 * 
 */
package neptune.web.client.model.topology;

import java.util.ArrayList;

import com.google.gwt.user.client.rpc.IsSerializable;

/**
 * @author Roberto Bifulco [info@robertobifulco.it, robertobifulco.it]
 * @author Luigi Lorenzo Arpino [luigiarpino@yahoo.it]
 * 
 */
public class SerializableTopology implements IsSerializable {

	/*
	 * Il nome della topologia
	 */
	private String name;
	
	/**
	 * La descrizione della topologia
	 */
	private String description;
	/*
	 * I nodi della topologia
	 */
	private ArrayList<SerializableNode> nodes = new ArrayList<SerializableNode>(
			0);
	/*
	 * I link della topologia
	 */
	private ArrayList<SerializableLink> links = new ArrayList<SerializableLink>(
			0);
	/*
	 * Timestamp dell'ultima modifica di questa topologia, sul server
	 */
	private long serverModificationTimestamp;

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public ArrayList<SerializableNode> getNodes() {
		return nodes;
	}

	public void setNodes(ArrayList<SerializableNode> nodes) {
		this.nodes = nodes;
	}

	public ArrayList<SerializableLink> getLinks() {
		return links;
	}

	public void setLinks(ArrayList<SerializableLink> links) {
		this.links = links;
	}

	public long getServerModificationTimestamp() {
		return serverModificationTimestamp;
	}

	public void setServerModificationTimestamp(long serverModificationTimestamp) {
		this.serverModificationTimestamp = serverModificationTimestamp;
	}

	public void removeNode(SerializableNode node) {
		for (int i=0; i< nodes.size(); i++){
			if(nodes.get(i).getId().equals(node.getId())){
				nodes.remove(i);
				break;
			}
		}
	}
	
	public void removeLink(SerializableLink link) {
		for (int i=0; i< links.size(); i++){
			if(links.get(i).getId().equals(link.getId())){
				links.remove(i);
				break;
			}
		}
	}

	public SerializableNode getNode(String nodeId){
		for (int i = 0; i < nodes.size(); i++) {
			if(nodes.get(i).getId().equals(nodeId))
				return nodes.get(i);		
		}
		return null;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}
}